Add Decimal32, Decimal64, Decimal128#100729
Conversation
|
Note regarding the |
|
This is on my radar to take a look at; just noting it might be a bit delayed due to other priorities for the .NET 9 release. CC. @jeffhandley |
|
Hi @PranavSenthilnathan, I have added more test cases following your suggestions:
|
|
@RaymondHuy looks like there's still a couple test failures:
Both are comparing zero ( |
Resolve #81376 --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Co-authored-by: Tanner Gooding <tagoo@outlook.com> Co-authored-by: Jeff Handley <jeffhandley@users.noreply.github.com>
|
I have independently developed decimal128 support for C# and 7 other language implementations. decimal128.com |
|
Thanks for the offer. I think we've got it covered for .NET 11 and have used the well tested Intel DFP as the foundational starting point, plus I've already done some optimization work on top. There will be more opportunities for tuning and improving things in .NET 12+ and you're welcome to contribute there, just make sure to open an issue and discuss large changes or refactorings first. |
|
Thank you for your prompt response.
IEEE 754-2019 leaves some aspects of NaN handling unspecified. I chose to use Cowlishaw GDAS behavior. I am very glad you folks are doing this. :) |
|
We're already using the Intel test vectors from their libraries, as well as a general oracle test bed for ad-hoc local validation beyond the general inner loop validation that runs as part of every CI, which particularly cover edge case behaviors, cohort handling, NaN handling, etc I would be interested in what aspects of NaN you believe are under-specified. The spec has pretty strict requirements around the handling of NaNs, canonicalization to the preferred exponent, recommended (but not required) propagation of canonical payloads, handling of signaling vs quiet NaNs, etc. The areas that are open ended tend to have the same general recommendations as binary floating-point numbers and the same official recommendations on how they should be handled. |
Intel handles this differently from Cowlishaw/GDAS. |
|
That is the same area as binary floating-point, which is that when 2 or more NaN inputs are present, the precise NaN returned is undefined (and often deviates across platforms). Which is returned does not matter and implementations should not be dependent on it, again same as with binary floating-point (and will often trivially be broken by basic compiler or hardware optimizations, such as allowing In .NETs case, we prefer the first occurring |
If you folks are going to take the payload of the first NaN then I will consider changing my library to do the same. Admittedly NaN payload is not a very big deal, but I think we can agree that it would be best for decimal floating point behavior to be the same across platforms. Taking the first prob would simplify things (slightly) for fma. |
Not really, IMO. Because it is already inconsistent across platforms and has been for 40 years. It is even inconsistent within a single platform due to legal and common optimizations, even when following strict IEEE 754 compliance mode with propagation (again, because compilers often trivially change Code should in general just be checking for -- Notably this also means that the .NET implementation is not strictly first NaN to what the user wrote either, its rather what ends up as the first |
|
good points |
Resolve #81376